import 'package:flutter/material.dart';

class TabViewPage02 extends StatelessWidget {
  TabViewPage02({Key? key}) : super(key: key);

  final tabs = ["新闻", "历史", "图片"];

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: tabs.length,
      child: Scaffold(
        appBar: AppBar(
          title: const Text("TabViewPage02"),
          bottom: TabBar(
            tabs: tabs
                .map((e) => Tab(
                      text: e,
                    ))
                .toList(),
          ),
        ),
        body: TabBarView(
          children: tabs.map(
            (e) {
              return KeepAlive(
                keepAlive: true,
                child: Container(
                  alignment: Alignment.center,
                  child: Text(
                    e,
                    textScaleFactor: 5,
                  ),
                ),
              );
            },
          ).toList(),
        ),
      ),
    );
  }
}
